<template>
  <div id="necessaryDetails">
    <div v-show="pageloading" style="margin:20px">读取中...</div>
    <div v-show="!pageloading" style="margin-left:20px">
      <div id="edit1" v-show="substep===1">
        <el-form ref="editForm1" :model="editForm1" label-width="150px">
          <el-form-item label="审核人" style="float:left">
            <span class="selectioncontent">
              {{editForm1.verifyUserName}}
            </span>
          </el-form-item>
          <el-form-item label="审核时间" prop="verifyTime" style="float:left">
            <span class="selectioncontent">
              {{editForm1.verifyTime}}
            </span>
          </el-form-item>
          <el-form-item label="是否存在问题" prop="hasProblem" style="clear:both;float:left">
            <span class="selectioncontent">
              {{myint2sf(editForm1.hasProblem)}}
            </span>
          </el-form-item>
          <el-form-item label="存在问题" prop="problemComment" style="float:left" v-show="editForm1.hasProblem===1">
            <span class="selectioncontent">
              {{editForm1.problemComment}}
            </span>
          </el-form-item>
          <el-form-item label="附件" prop="file1" style="clear:both;">
            <div  v-for="(item, index) of fileList1" :key="index"><a :href="$http.defaults.baseURL+$http.defaults.selectionAPI+'api/gen/file/download?id='+item.id">{{item.fileName}}.{{item.fileType}}</a></div>
          </el-form-item>
        </el-form>
        <div style="font-size:var(--size16) !important;line-height:200%">
          <h1>办理提示</h1>
          <ul v-show="step21&&step21.length>0">
            <li v-for="item of step21" :key="item.id" style="padding-right:20px"><b>{{item.sendUserName}} [{{item.sendTime}}]：</b>{{item.opinion}}</li>
          </ul>
        </div>
      </div>
      <div id="edit2" v-show="substep===2">
        <el-form ref="editForm2" :model="editForm2" label-width="150px">
          <el-form-item label="审核人" style="float:left">
            <span class="selectioncontent">
            {{editForm2.verifyUserName}}
            </span>
          </el-form-item>
          <el-form-item label="审核时间" prop="verifyTime" style="float:left">
            <span class="selectioncontent">
            {{editForm2.verifyTime}}
            </span>
          </el-form-item>
          <el-form-item label="认定结果" prop="confirmResult" style="clear:both;">
            <span class="selectioncontent">
            {{confirmResult(editForm2.confirmResult)}}
            </span>
          </el-form-item>
          <el-form-item label="是否存在问题" prop="hasProblem" style="clear:both;float:left">
            <span class="selectioncontent">
            {{myint2sf(editForm2.hasProblem)}}
            </span>
          </el-form-item>
          <el-form-item label="存在问题" prop="problemComment" style="float:left" v-show="editForm2.hasProblem===1">
            <span class="selectioncontent">
            {{editForm2.problemComment}}
            </span>
          </el-form-item>
          <el-form-item label="附件" prop="file" style="clear:both;">
            <div  v-for="(item, index) of fileList2" :key="index"><a :href="$http.defaults.baseURL+$http.defaults.selectionAPI+'api/gen/file/download?id='+item.id">{{item.fileName}}.{{item.fileType}}</a></div>
          </el-form-item>
        </el-form>
        <div style="font-size:var(--size16) !important;line-height:200%">
          <h1>办理提示</h1>
          <ul v-show="step22&&step22.length>0">
            <li v-for="item of step22" :key="item.id" style="padding-right:20px"><b>{{item.sendUserName}} [{{item.sendTime}}]：</b>{{item.opinion}}</li>
          </ul>
        </div>
      </div>
      <div id="edit3" v-show="substep===3">
        <el-form ref="editForm3" :model="editForm3" label-width="150px" v-show="editForm3.checkFlag">
          <h3>征求驻部纪检监察组意见</h3>
          <el-form-item label="征求时间" prop="askingTime" style="float:left">
            <span class="selectioncontent">
            {{editForm3.askingTime}}
            </span>
          </el-form-item>
          <el-form-item label="反馈时间" prop="feedbackTime" style="float:left">
            <span class="selectioncontent">
            {{editForm3.feedbackTime}}
            </span>
          </el-form-item>
          <el-form-item label="反馈意见" prop="feedbackOpinion" style="clear:both;">
            <span class="selectioncontent">
            {{editForm3.feedbackOpinion}}
            </span>
          </el-form-item>
          <el-form-item label="是否存在问题" prop="hasProblem" style="clear:both;float:left">
            <span class="selectioncontent">
            {{myint2sf(editForm2.hasProblem)}}
            </span>
          </el-form-item>
          <el-form-item label="存在问题" prop="problemComment" style="float:left" v-show="editForm3.hasProblem===1">
            <span class="selectioncontent">
            {{editForm3.problemComment}}
            </span>
          </el-form-item>
          <el-form-item label="附件" prop="file" style="clear:both;">
            <div  v-for="(item, index) of fileList3" :key="index"><a :href="$http.defaults.baseURL+$http.defaults.selectionAPI+'api/gen/file/download?id='+item.id">{{item.fileName}}.{{item.fileType}}</a></div>
          </el-form-item>
        </el-form>
        <el-form ref="editForm3b" :model="editForm3b" label-width="150px" v-show="editForm3b.checkFlag2">
          <h3>征求机关纪委意见</h3>
          <el-form-item label="征求时间" prop="askingTime" style="float:left">
            <span class="selectioncontent">
            {{editForm3b.askingTime}}
            </span>
          </el-form-item>
          <el-form-item label="反馈时间" prop="feedbackTime" style="float:left">
            <span class="selectioncontent">
            {{editForm3b.feedbackTime}}
            </span>
          </el-form-item>
          <el-form-item label="反馈意见" prop="feedbackOpinion" style="clear:both;">
            <span class="selectioncontent">
            {{editForm3b.feedbackOpinion}}
            </span>
          </el-form-item>
          <el-form-item label="是否存在问题" prop="hasProblem" style="clear:both;float:left">
            <span class="selectioncontent">
            {{myint2sf(editForm3b.hasProblem)}}
            </span>
          </el-form-item>
          <el-form-item label="存在问题" prop="problemComment" style="float:left" v-show="editForm3b.hasProblem===1">
            <span class="selectioncontent">
            {{editForm3b.problemComment}}
            </span>
          </el-form-item>
          <el-form-item label="附件" prop="file" style="clear:both;">
            <div  v-for="(item, index) of fileList3b" :key="index"><a :href="$http.defaults.baseURL+$http.defaults.selectionAPI+'api/gen/file/download?id='+item.id">{{item.fileName}}.{{item.fileType}}</a></div>
          </el-form-item>
        </el-form>
        <div style="font-size:var(--size16) !important;line-height:200%">
          <h1>办理提示</h1>
          <ul v-show="step23&&step23.length>0">
            <li v-for="item of step23" :key="item.id" style="padding-right:20px"><b>{{item.sendUserName}} [{{item.sendTime}}]：</b>{{item.opinion}}</li>
          </ul>
        </div>
      </div>
      <div id="edit4" v-show="substep===4">
        <el-form ref="editForm4" :model="editForm4" label-width="150px">
          <el-form-item label="是否有可查性线索举报" prop="hasTraceableClues" style="clear:both" label-width="200px">
            <span class="selectioncontent">
            {{myint2sf(editForm4.hasTraceableClues)}}
            </span>
          </el-form-item>
          <el-form-item label="调查核实情况" prop="verifySituation" style="clear:both" v-show="editForm4.hasTraceableClues===1">
            <span class="selectioncontent">
            {{editForm4.verifySituation}}
            </span>
          </el-form-item>
          <el-form-item label="附件" prop="file" style="clear:both;">
            <div  v-for="(item, index) of fileList4" :key="index"><a :href="$http.defaults.baseURL+$http.defaults.selectionAPI+'api/gen/file/download?id='+item.id">{{item.fileName}}.{{item.fileType}}</a></div>
          </el-form-item>
        </el-form>
        <div style="font-size:var(--size16) !important;line-height:200%">
          <h1>办理提示</h1>
          <ul v-show="step24&&step24.length>0">
            <li v-for="item of step24" :key="item.id" style="padding-right:20px"><b>{{item.sendUserName}} [{{item.sendTime}}]：</b>{{item.opinion}}</li>
          </ul>
        </div>
      </div>
      <!-- {{resultFtsb}} -->
    </div>
  </div>
</template>
<script>
export default {
  props: ['substep', 'personid'],
  watch: {
    substep: {
      handler (val, oldVal) {
        console.log('substep has changed', val)
        this.getItem()
        this.getftsb()
      },
      immediate: true
    },
    personid: {
      handler (val, oldVal) {
        console.log('personid has changed', val)
        this.getItem()
        this.getftsb()
      },
      immediate: true
    }
  },
  data () {
    return {
      step21: [],
      step22: [],
      step23: [],
      step24: [],
      resultFtsb: '',
      pageloading: true,
      username: '张某某',
      editForm1: {
        verifyTime: '',
        hasProblem: 0,
        problemComment: ''
      },
      fileList1: [],
      editForm2: {
        verifyTime: '',
        confirmResult: '',
        hasProblem: 0,
        problemComment: ''
      },
      fileList2: [],
      editForm3: {
        askingTime: '',
        feedbackTime: '',
        feedbackOpinion: '',
        hasProblem: 0,
        problemComment: ''
      },
      fileList3: [],
      files3: [],
      editForm3b: {
        askingTime: '',
        feedbackTime: '',
        feedbackOpinion: '',
        hasProblem: 0,
        problemComment: ''
      },
      fileList3b: [],
      editForm4: {
        hasTraceableClues: 0,
        verifySituation: ''
      },
      fileList4: []
    }
  },
  methods: {
    getItem () {
      this.pageloading = true
      this.editForm1.verifyTime = ''
      this.editForm1.hasProblem = ''
      this.editForm1.problemComment = ''
      this.fileList1 = []
      this.editForm2.verifyTime = ''
      this.editForm2.confirmResult = ''
      this.editForm2.hasProblem = ''
      this.editForm2.problemComment = ''
      this.fileList2 = []
      this.editForm3.askingTime = ''
      this.editForm3.feedbackTime = ''
      this.editForm3b.askingTime = ''
      this.editForm3b.feedbackTime = ''
      this.editForm3.feedbackOpinion = ''
      this.editForm3b.feedbackOpinion = ''
      this.editForm3.hasProblem = ''
      this.editForm3b.hasProblem = ''
      this.editForm3.problemComment = ''
      this.editForm3b.problemComment = ''
      this.fileList3 = []
      this.fileList3b = []
      this.editForm4.hasTraceableClues = ''
      this.editForm4.verifySituation = ''
      this.fileList4 = []
      if (this.personid) {
        let para = {
          personId: this.personid
        }
        this.$http
          .post(this.$http.defaults.selectionAPI + `api/selection/necessary/getPersonStepInfo`, para)
          .then(response => {
            if (response.data.success) {
            // 获取分项信息后具体处理
              this.pageloading = false
              let mydate1 = new Date(response.data.result.cadreArchivesVerifyTime)
              this.editForm1.verifyUserName = response.data.result.cadreArchivesVerifyUserName
              this.editForm1.verifyTime = this.mydateFtt('yyyy年MM月dd日', mydate1)
              this.editForm1.hasProblem = response.data.result.cadreArchivesHasProblem
              this.editForm1.problemComment = response.data.result.cadreArchivesProblemComment
              this.fileList1 = response.data.result.cadreArchivesFiles
              let mydate2 = new Date(response.data.result.personalMattersVerifyTime)
              this.editForm2.verifyUserName = response.data.result.personalMattersVerifyUserName
              this.editForm2.verifyTime = this.mydateFtt('yyyy年MM月dd日', mydate2)
              this.editForm2.confirmResult = response.data.result.personalMattersConfirmResult
              this.editForm2.hasProblem = response.data.result.personalMattersHasProblem
              this.editForm2.problemComment = response.data.result.personalMattersProblemComment
              this.fileList2 = response.data.result.personalMattersFiles
              let mydate31 = new Date(response.data.result.solicitingOpinionsAskingTime)
              this.editForm3.askingTime = this.mydateFtt('yyyy年MM月dd日', mydate31)
              let mydate32 = new Date(response.data.result.solicitingOpinionsFeedbackTime)
              this.editForm3.feedbackTime = this.mydateFtt('yyyy年MM月dd日', mydate32)
              let mydate31b = new Date(response.data.result.solicitingOpinionsAskingTime2)
              this.editForm3b.askingTime = this.mydateFtt('yyyy年MM月dd日', mydate31b)
              let mydate32b = new Date(response.data.result.solicitingOpinionsFeedbackTime2)
              this.editForm3b.feedbackTime = this.mydateFtt('yyyy年MM月dd日', mydate32b)
              this.editForm3.feedbackOpinion = response.data.result.solicitingOpinionsFeedbackOpinion
              this.editForm3b.feedbackOpinion = response.data.result.solicitingOpinionsFeedbackOpinion2
              this.editForm3.hasProblem = response.data.result.solicitingOpinionsHasProblem
              this.editForm3b.hasProblem = response.data.result.solicitingOpinionsHasProblem2
              this.editForm3.problemComment = response.data.result.solicitingOpinionsProblemComment
              this.editForm3b.problemComment = response.data.result.solicitingOpinionsProblemComment2
              this.editForm3.checkFlag = response.data.result.checkFlag
              this.editForm3b.checkFlag2 = response.data.result.checkFlag2
              this.fileList3 = response.data.result.solicitingOpinionsFiles1
              this.fileList3b = response.data.result.solicitingOpinionsFiles2
              this.editForm4.hasTraceableClues = response.data.result.clueReportingHasTraceableClues
              this.editForm4.verifySituation = response.data.result.clueReportingVerifySituation
              this.fileList4 = response.data.result.clueReportingFiles
              this.step21 = response.data.result.step21
              this.step22 = response.data.result.step22
              this.step23 = response.data.result.step23
              this.step24 = response.data.result.step24
            } else {
              this.$message({
                message: '获取失败:' + response.data.message,
                type: 'error'
              })
            }
          })
          .catch(error => {
            this.$message({
              message: '网络获取失败:' + error,
              type: 'error'
            })
            this.FormLoading = false
          })
      }
    },
    getftsb () {
      if (this.personid) {
        let para = {
          personId: this.personid
        }
        this.$http
          .post(this.$http.defaults.selectionAPI + `api/selection/necessary/getPersonStepInfo`, para)
          .then(response => {
            if (response.data.success) {
              let result1 = ''
              let result2 = ''
              let result3 = ''
              let result4 = ''
              if (response.data.result.stateCadreArchives === -1 || response.data.result.resultCadreArchives === '') {
                result1 = '无'
              } else {
                result1 = response.data.result.resultCadreArchives
              }
              if (response.data.result.statePersonalMatters === -1 || response.data.result.resultPersonalMatters === '') {
                result2 = '无'
              } else {
                result2 = response.data.result.resultPersonalMatters
              }
              if (response.data.result.stateSolicitingOpinions === -1 || response.data.result.resultSolicitingOpinions === '') {
                result3 = '无'
              } else {
                result3 = response.data.result.resultSolicitingOpinions
              }
              if (response.data.result.stateClueReporting === -1 || response.data.result.resultClueReporting === '') {
                result4 = '无'
              } else {
                result4 = response.data.result.resultClueReporting
              }
              this.resultFtsb = '查核干部档案：' + result1 + '；查核有关事项：' + result2 + '；征求纪检监察部门意见：' + result3 + '；线索举报调查：' + result4
            } else {
              this.$message({
                message: '获取失败:' + response.data.message,
                type: 'error'
              })
            }
          })
          .catch(error => {
            this.$message({
              message: '网络获取失败:' + error,
              type: 'error'
            })
          })
      }
    },
    mydateFtt (fmt, date) { // author: meizz\
      if (date) {
        let mydate = date
        var o = {
          'M+': mydate.getMonth() + 1, // 月份
          'd+': mydate.getDate(), // 日
          'h+': mydate.getHours(), // 小时
          'm+': mydate.getMinutes(), // 分
          's+': mydate.getSeconds(), // 秒
          'q+': Math.floor((mydate.getMonth() + 3) / 3), // 季度
          'S': mydate.getMilliseconds() // 毫秒
        }
        if (/(y+)/.test(fmt)) { fmt = fmt.replace(RegExp.$1, (mydate.getFullYear() + '').substr(4 - RegExp.$1.length)) }
        for (var k in o) {
          if (new RegExp('(' + k + ')').test(fmt)) { fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) }
        }
        return fmt
      } else {
        return null
      }
    },
    myint2sf (str) {
      if (str) {
        return '是'
      } else {
        return '否'
      }
    },
    confirmResult (str) {
      if (str === 1) {
        return '基本一致'
      }
      if (str === 2) {
        return '漏报较轻'
      }
      if (str === 3) {
        return '漏报较重'
      }
      if (str === 4) {
        return '瞒报'
      }
      if (str === 5) {
        return '存在其他违法违纪'
      }
    }
  },
  mounted () {
    this.getItem()
  }
}
</script>
<style>
#necessaryDetails .el-form-item__content{
  font-weight: bolder
}
</style>
